package com.csii.result;


import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * @description: 分页返回对象
 * @author: panChuanJiang
 * @create: 2021-02-24 16:02
 */
@Data
@Accessors(chain = true)
public class PageVo<T> {
    /**
     * 每页条数
     */
    private int pageSize;

    /**
     *当前页起始数
     */
    private int currentIndex;

    /**
     *当前页
     */
    private int pageNo;
    /*
     *总条数
     */
    private long recordNumber;
    /**
     * 分页数据
     */
    private List<T> records;

    public static PageVo getPageVoFromIPage(IPage page){
        PageVo<?> pageVo = new PageVo();
        pageVo.setPageNo((int)page.getCurrent())
                .setPageSize((int)page.getSize())
                .setRecordNumber(page.getTotal())
                .setRecords(page.getRecords());
        return pageVo;
    }
}
